//
//  LSLevinBookListViewCell.m
//  LaSaCivilAffairsDepartment
//
//  Created by 聂志康 on 2019/8/20.
//  Copyright © 2019 wpkj. All rights reserved.
//

#import "LSLevinBookListViewCell.h"
#import "LSLevinBookListModel.h"
#import "LSMeassgeCenterListModel.h"

@interface LSLevinBookListViewCell ()
@property (nonatomic, strong) UILabel *mainTitleLabel;
@property (nonatomic, strong) UILabel *subTitleLabel;
@property (nonatomic, strong) UILabel *rightTitleLabel;
@end

@implementation LSLevinBookListViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellEditingStyleNone;
        [self.contentView addSubview:self.mainTitleLabel];
        [self.contentView addSubview:self.subTitleLabel];
        [self.contentView addSubview:self.rightTitleLabel];
    }
    return self;
}

- (void)setModel:(LSLevinBookListModel *)model {
    _model = model;
    self.mainTitleLabel.text = model.fileTitle;
    self.subTitleLabel.text = [[ValidateUtils validateNull:self.fileClassifyDict[model.fileClassify]] isEqualToString:@""] ? model.fileClassify : self.fileClassifyDict[model.fileClassify];
    self.rightTitleLabel.text = model.isFiling.integerValue == 0 ? @"未归档" : @"已归档";
}

- (void)setCenterListModel:(LSMeassgeCenterListModel *)centerListModel {
    _centerListModel = centerListModel;
    self.mainTitleLabel.text = centerListModel.title;
    self.subTitleLabel.text = [ValidateUtils validateNull:centerListModel.content];
    self.rightTitleLabel.text = centerListModel.state.integerValue == 1 ? @"已读" : @"未读";
}

- (void)layoutSubviews {
    [super layoutSubviews];
    WS
    [self.mainTitleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.contentView.mas_left).with.offset(12);
        make.top.equalTo(weakSelf.contentView.mas_top).with.offset(8);
        make.right.equalTo(weakSelf.contentView.mas_right).with.offset(-100);
    }];
    [self.subTitleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.contentView.mas_left).with.offset(12);
        make.bottom.equalTo(weakSelf.contentView.mas_bottom).with.offset(-8);
        make.right.equalTo(weakSelf.contentView.mas_right).with.offset(-100);
    }];
    [self.rightTitleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(weakSelf.contentView.mas_right).with.offset(-30);
        make.centerY.equalTo(weakSelf.contentView.mas_centerY);
    }];
}

- (UILabel *)mainTitleLabel {
    if (!_mainTitleLabel) {
        _mainTitleLabel = [[UILabel alloc] init];
        _mainTitleLabel.textColor = hexColor(333333);
        _mainTitleLabel.font = [UIFont systemFontOfSize:16];
    }
    return _mainTitleLabel;
}

- (UILabel *)subTitleLabel {
    if (!_subTitleLabel) {
        _subTitleLabel = [[UILabel alloc] init];
        _subTitleLabel.textColor = hexColor(666666);
        _subTitleLabel.font = [UIFont systemFontOfSize:13];
    }
    return _subTitleLabel;
}

- (UILabel *)rightTitleLabel {
    if (!_rightTitleLabel) {
        _rightTitleLabel = [[UILabel alloc] init];
        _rightTitleLabel.textColor = hexColor(666666);
        _rightTitleLabel.font = [UIFont systemFontOfSize:13];
        _rightTitleLabel.textAlignment = NSTextAlignmentRight;
    }
    return _rightTitleLabel;
}

- (NSDictionary *)fileClassifyDict {
    if (!_fileClassifyDict) {
        _fileClassifyDict = @{@"central":@"中央文件",
                              @"autonomousRegion":@"自治区文件",
                              @"MuniGovernment":@"市委市政府文件",
                              @"bureau":@"本局文件",
                              @"MuniDepartments":@"市直相关部门文件"
                              };
    }
    return _fileClassifyDict;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
